-
Notifications
You must be signed in to change notification settings - Fork 71
Start removing pre-Python 3.8 code #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Start removing pre-Python 3.8 code #214
Conversation
3b1f85e to
a8a370b
Compare
|
|
e6b6b6d to
3e63ada
Compare
|
Actually, I don't mind looking at this as one big PR. But #124 should go in first. |
|
#124 is in. Want to take off the "Draft" status? |
src/cffi/api.py
Outdated
| try: | ||
| callable | ||
| except NameError: | ||
| # Python 3.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Python 3.1 |
src/cffi/recompiler.py
Outdated
| if isinstance(s, unicode): | ||
| s = s.encode('ascii') | ||
| super(NativeIO, self).write(s) | ||
| NativeIO = io.StringIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably refactor out NativeIO
src/cffi/vengine_gen.py
Outdated
| prefix = 'PyInit_' | ||
| modname = self.verifier.get_module_name() | ||
| prnt("void %s%s(void) { }\n" % (prefix, modname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
| prefix = 'PyInit_' | |
| modname = self.verifier.get_module_name() | |
| prnt("void %s%s(void) { }\n" % (prefix, modname)) | |
| modname = self.verifier.get_module_name() | |
| prnt(f"void PyInit_{modname}(void) {{ }}\n") |
mattip
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot here, and probably a lot more to do. It is fine to do this in a couple of PRs though, we don't have to get it all in one PR.
|
Yes, I'm mostly applying pyupgrade and refurb ruff rules, to handle everything that can be fixed or at least detected automatically. I was thinking of starting a manual pass once this PR is in. But sure, I can apply the above suggestions. Still haven't applied UP030, UP031, UP032. I suggest a dedicated PR for these rules. |
3e63ada to
1f61c83
Compare
2bc183e to
d396812
Compare
d396812 to
d499d89
Compare
UP004 Class inherits from `object`
UP008 Use `super()` instead of `super(__class__, self)`
UP009 UTF-8 encoding declaration is unnecessary
UP010 Unnecessary `__future__` import for target Python version Manually removed comments about Unicode literals.
In Python 3, `io.open` is an alias for `open`. This is a manual change, not detected by ruff.
UP024 Replace aliased errors with `OSError`
UP025 Remove unicode literals from strings
UP028 Replace `yield` over `for` loop with `yield from`
UP035 Import from `collections.abc` instead: `Callable` Co-authored-by: Matti Picus <[email protected]>
FURB129 Instead of calling `readlines()`, iterate over file object directly
FURB188 Prefer `str.removeprefix()` over conditionally replacing with slice.
E703 Statement ends with an unnecessary semicolon
E711 Comparison to `None` should be `cond is not None`
E713 Test for membership should be `not in`
d499d89 to
fc735bf
Compare
|
Rebased and deferred UP036 to a PR of its own. |
Companion to #124.
Mostly applied ruff pyupgrade (UP) rules, and some pycodestyle (E) and refurb (FURB) rules.
Edit: I have left out some pyupgrade (UP) rules: